<!--
 * @Description: 关于我们页面组件，未完成
 * @Author: hai-27
 * @Date: 2020-02-07 16:23:00
 * @LastEditors: hai-27
 * @LastEditTime: 2020-03-12 19:36:46
 -->
<template>
  <div class="about" id="about" name="about">
    <div class="about-header">
      <div class="about-title">
        <i class="el-icon-tickets" style="color: #ff6700">正品验证</i>
      </div>
    </div>
    <div class="about-content">
      <el-card>
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="商品验证码">
            <el-input
              v-model="formInline.code"
              placeholder="请输入验证ID"
            ></el-input>
          </el-form-item>
          <el-form-item label="商品ID">
            <el-input
              v-model="formInline.goodsId"
              placeholder="请输入商品ID"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </el-card>
      <el-card>
        <div class="flex">
          <div class="flexitem">
            <img
              v-if="this.goodisflase == '真'"
              :src="'http://127.0.0.1:80/' + this.goodsdata.goodsImg"
              alt=""
            />
            <span v-else> 请输入验证码获取商品信息 </span>
          </div>
          <div class="flexitem" v-if="this.goodisflase == '真'">
            <div class="info">商品名称： {{ this.goodsdata.goodsName }}</div>
            <div class="info">商品来源： {{ this.goodsdata.goodsOrgin }}</div>
            <div class="info">生产日期： {{ this.goodsdata.goodsTimes }}</div>
            <div class="info">
              <el-tag disable-transitions size="medium">正品</el-tag>
            </div>
          </div>
          <div class="flexitem" v-if="this.goodisflase == '假'">
            <h1>查询不到该商品请注意辨别真伪</h1>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>
<script>
// import MyMarkdown from "../components/MyMarkdown";
import { queryGoodsById, queryTrueAndFalserf } from "../api/index";
export default {
  data() {
    return {
      formInline: {
        goodsId: "",
        userId: "",
        code: "",
      },
      goodsdata: {},
      goodisflase: "",
    };
  },
  methods: {
    onSubmit() {
      console.log("submit!");
      this.formInline.userId = JSON.parse(localStorage.getItem("user")).userId;
      // console.log(JSON.parse(localStorage.getItem("user")));
      if (this.formInline.goodsId == "") {
        this.$notify({
          title: "警告",
          message: "请输入商品ID ",
          type: "warning",
        });
      } else if (this.formInline.code == "")
        this.$notify({
          title: "警告",
          message: "请输入商品验证码",
          type: "warning",
        });
      else {
        queryTrueAndFalserf({
          ...this.formInline,
        })
          .then((res) => {
            if (res.code == 200) {
              this.notifySucceed(res.message);
              this.goodisflase = res.data;
              console.log(this.goodisflase);
              if (this.goodisflase == "真") {
                this.getgoodinfo()
              }else{
                return
              }
            } else {
              this.notifyError(res.message);
            }
            if (res.data == null) {
              this.goodisflase = true;
              console.log(this.goodisflase);
            }
          })
          .catch((err) => {});
      }
    },
    getgoodinfo() {
      // this.formInline.userId = JSON.parse(localStorage.getItem("user")).userId;
      queryGoodsById({
        goodsId:this.formInline.goodsId
      })
        .then((res) => {
          this.goodsdata = res.data;
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  // components: {
  //   MyMarkdown
  // }
};
</script>
<style scoped>
.flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 500px;
  /* border: 1px solid #ccc; */
  padding: 20px;
  box-sizing: border-box;
}
.flex .flexitem {
  width: 45%;
  height: 90%;
  /* border: 1px solid #ccc; */
  font-size: 24px;
  text-align: center;
  line-height: 414px;
  transition: all 0.5s linear;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.flex .flexitem .info {
  height: 50px;
  line-height: 50px;
  font-size: 15px;
  /* border: 1px solid #ccc; */
  font-weight: bold;
}
.flex .flexitem:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
}
.flex .flexitem img {
  width: 100%;
  height: 100%;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.about {
  background-color: #f5f5f5;
}
.about .about-header {
  height: 64px;
  background-color: #fff;
  border-bottom: 2px solid #ff6700;
}
.about .about-header .about-title {
  width: 1225px;
  margin: 0 auto;
  height: 64px;
  line-height: 64px;
  font-size: 28px;
}
.about .content {
  padding: 20px 0;
  width: 1225px;
  margin: 0 auto;
}
.about .content .goods-list {
  margin-left: -13.7px;
  overflow: hidden;
}
.about .about-content {
  width: 1225px;
  margin: 0 auto;
  background-color: #fff;
}
</style>
